<html>
	<head>
		<title>xpAjax example</title>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
		<script type="text/javascript" src="http://classes.rlrossi.com/lib/js/prototypes.js"></script>
		<script type="text/javascript" src="http://classes.rlrossi.com/js/xpajax/xpAjax.js"></script>
		<script type="text/javascript">
			var ajax = new xpAjax("http://classes.rlrossi.com/js/xpajax");

			/* Adds 'replaceAll' Method to Strings Javascript Platform */
			if(typeof(String.prototype.replaceAll) === "undefined")
			  { String.prototype.replaceAll = function(search,replacement)
				  { var newString = this;
					while(newString.indexOf(search) > -1)
					  { newString = newString.replace(search,replacement);
					  }
					return newString;
				  };
			  }

			function getAddress(zip)
			  { ajax.send("xpAjaxexample.php","getAddressResult","{'sourceparms':'"+ajax._uservalues+"','zipcode':21511290}");
			  }

			function getAddressResult(result)
			  { if(result.error)
				  { alert(result.msg + (result.src ? ("\n"+result.src) : ""));
					return;
				  }

				document.getElementById("caption").innerHTML	  = result.caption;
				document.getElementById("zip").innerHTML		  = "ZIP CODE:    &nbsp;"+ result.zip;
				document.getElementById("address").innerHTML	  = "Address:     &nbsp;"+ result.address;
				document.getElementById("neighborhood").innerHTML = "Neighborhood:&nbsp;"+ result.neighborhood;
				document.getElementById("city").innerHTML		  = "City:        &nbsp;"+ result.city;
				document.getElementById("state").innerHTML		  = "State:       &nbsp;"+ result.state;
				document.getElementById("country").innerHTML	  = "Country:     &nbsp;"+ result.country;
						
				return;
			  }
		</script>
	</head>
	<body onload="document.getElementById('zip').readOnly=true;">
		<div style="position:absolute;top:25px;left:50px">
			<form id="testajax" method="post" action="#">
				<p>Get the address for <input type="text" id="zipcode" value="10019" size="5">, NY, USA
					<input type="button" id="GetTheAdress" value="Show me the address" onClick="getAddress(10019);" />
				</p>
			</form>
			<p id="caption"></p>
			<p id="zip"></p>
			<p id="address"></p>
			<p id="neighborhood"></p>
			<p id="city"></p>
			<p id="state"></p>
			<p id="country"></p>
		</div>
	</body>
</html>
